package com.wangshouyu.mp.message;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

/**
 * @author 王守钰
 * @date 2020年12月07日 13:51
 * @description 菜单消息
 */
public class MenuMessage implements Serializable {

    /**
     * 头内容
     */
    @SerializedName(value = "head_content")
    @JsonProperty(value = "head_content")
    @JSONField(name = "head_content")
    private String headContent;

    /**
     * 尾内容
     */
    @SerializedName(value = "tail_content")
    @JsonProperty(value = "tail_content")
    @JSONField(name = "tail_content")
    private String tailContent;

    /**
     * 按钮
     */
    @SerializedName(value = "list")
    @JsonProperty(value = "list")
    @JSONField(name = "list")
    private List<MenuButton> buttons;

    public String getHeadContent() {
        return headContent;
    }

    public void setHeadContent(String headContent) {
        this.headContent = headContent;
    }

    public String getTailContent() {
        return tailContent;
    }

    public void setTailContent(String tailContent) {
        this.tailContent = tailContent;
    }

    public List<MenuButton> getButtons() {
        return buttons;
    }

    public void setButtons(List<MenuButton> buttons) {
        this.buttons = buttons;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MenuMessage that = (MenuMessage) o;
        return Objects.equals(headContent, that.headContent) &&
                Objects.equals(tailContent, that.tailContent) &&
                Objects.equals(buttons, that.buttons);
    }

    @Override
    public int hashCode() {
        return Objects.hash(headContent, tailContent, buttons);
    }

    @Override
    public String toString() {
        return "MenuMessage{" +
                "headContent='" + headContent + '\'' +
                ", tailContent='" + tailContent + '\'' +
                ", buttons=" + buttons +
                '}';
    }

    /**
     * 菜单按钮
     */
    static class MenuButton{

        private String id;

        private String content;

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            MenuButton that = (MenuButton) o;
            return Objects.equals(id, that.id) &&
                    Objects.equals(content, that.content);
        }

        @Override
        public int hashCode() {
            return Objects.hash(id, content);
        }

        @Override
        public String toString() {
            return "MenuButton{" +
                    "id='" + id + '\'' +
                    ", content='" + content + '\'' +
                    '}';
        }
    }
}

